package com.multicampus.simplewiki.control;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import com.multicampus.simplewiki.ctrl.DocumentManager;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DeletePageController implements Controller {
	private DocumentManager documentManager;

	public void setDocumentManager(DocumentManager documentManager) {
		this.documentManager = documentManager;
	}

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		documentManager.deleteDocument(Integer.parseInt(request.getParameter("id")));
		
		return new ModelAndView("redirect:/viewpage.do");
	}
}